// 消息模块路由处理函数

// 引入jwt
const jwt = require('jsonwebtoken')
const secretKey = 'ethink'    // 密钥
const utils = require("../common/utils")
const server = require("../server/message")

// 发送招呼消息
exports.helloFriend = (req, res) => {
  // 好友id
  let { id, message, message_type } = req.body
  let token = req.get('Authorization').split(' ')[1]
  // 自己的id
  let user_id = jwt.verify(token, secretKey).id
  server.helloFirend(user_id, id, message, message_type).then(result => {
   return res.cc(result, 200)
  }).catch(e => {
    return res.cc(e)
  })
}